import { ElIcon } from 'element-plus'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import modal from './modal'
import EDialog from '@/components/Dialog/index.vue'
import EButton from '@/components/Button/index.vue'
import EPopover from '@/components/Popover/index.vue'
import Table from '@/components/Table/index.vue'
import NoData from '@/components/NoData/index.vue'
import Upload from '@/components/Upload/index.vue'
import Pagination from "@/components/Pagination/index.vue";
const components = import.meta.glob('@/components/*/index.js', { eager: true })

export default {
    install(app) {
        app.component('ElIcon', ElIcon)
        Object.entries(ElementPlusIconsVue).forEach(([key, component]) => {
            app.component(key, component)
        })

        Object.keys(components).forEach(key => {
            const component = components[key].default
            app.component(component.name, component)
        })
        // 模态框对象
        app.config.globalProperties.$modal = modal;
        // 自定义弹窗组件
        app.component('e-dialog', EDialog);
        // 自定义按钮组件
        app.component('e-button', EButton);
        // 自定义弹出框组件
        app.component('e-popover', EPopover);
        // 自定义表格组件
        app.component('e-table', Table);
        // 自定义无数据组件
        app.component('no-data', NoData);
        // 自定义上传组件
        app.component('e-upload', Upload);
        // 自定义分页组件
        app.component('Pagination', Pagination);
    }
}
